//
//  TripsTableViewCell.m
//  chanyou
//
//  Created by leon on 14/12/30.
//  Copyright (c) 2014年 wanli. All rights reserved.
//

#import "TripsTableViewCell.h"
#import "Masonry.h"
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation TripsTableViewCell
- (void)dealloc
{
    [_backgroundImgView release];
    [_nameLabel release];
    [_dateLabel release];
    [_userImgView release];
    [_userNameLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
//        self.backgroundImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 20, SCREEN_HEIGHT / 3.7 )];
        self.backgroundImgView = [[UIImageView alloc] init];
        _backgroundImgView.layer.cornerRadius = 3;
        _backgroundImgView.layer.masksToBounds = YES;
        [self.contentView addSubview:_backgroundImgView];


        self.userImgView = [[UIImageView alloc] init];

        [_backgroundImgView release];

        
        self.userImgView = [[UIImageView alloc] initWithFrame:CGRectMake(25, SCREEN_WIDTH / 2.45, self.contentView.frame.size.width / 8, self.contentView.frame.size.width / 8)];
        _userImgView.layer.cornerRadius = self.contentView.frame.size.width / 16;
        _userImgView.layer.masksToBounds = YES;
        [self.contentView addSubview:_userImgView];
        [_userImgView release];
        
//        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, SCREEN_WIDTH / 8.5, self.contentView.frame.size.width, self.contentView.frame.size.height * 2)];
        self.nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = [UIFont systemFontOfSize:18];
        _nameLabel.numberOfLines = 0;
        _nameLabel.font = [UIFont boldSystemFontOfSize:18];
        _nameLabel.shadowColor = [UIColor lightGrayColor];
        _nameLabel.highlighted = YES;
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        
//        self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, SCREEN_WIDTH / 2.6, self.contentView.frame.size.width / 2, self.contentView.frame.size.height / 3.5)];
        self.dateLabel = [[UILabel alloc] init];
        _dateLabel.tintColor = [UIColor whiteColor];
        _dateLabel.textColor = [UIColor whiteColor];
        _dateLabel.font = [UIFont systemFontOfSize:14];
        _dateLabel.shadowColor = [UIColor lightGrayColor];
        _dateLabel.highlighted = YES;
        [self.contentView addSubview:_dateLabel];

        
        self.userNameLabel = [[UILabel alloc] init];
        _userNameLabel.tintColor = [UIColor whiteColor];
        _userNameLabel.textColor = [UIColor whiteColor];
        _userNameLabel.shadowColor = [UIColor lightGrayColor];
        _userNameLabel.highlighted = YES;
        [self.contentView addSubview:_userNameLabel];
        

        [_dateLabel release];

    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [_backgroundImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(10, 10, 5, 10));
    }];

    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.contentView).width.insets(UIEdgeInsetsMake(10, 25, self.contentView.frame.size.height / 1.8, 20));
    }];
    
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(_nameLabel).insets(UIEdgeInsetsMake(self.contentView.frame.size.height / 4.3, 0, -30, 0));
    }];
    
    [_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(_userImgView).insets(UIEdgeInsetsMake(0, self.contentView.frame.size.width / 8, 0, self.contentView.frame.size.width / 8));
    }];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
